package com.newmacys.spring;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import com.newmacys.bag.bean.BagBean;

public class WebDispatcher extends DispatcherServlet {

	private static final long serialVersionUID = -1174826468653325328L;

	protected void noHandlerFound(HttpServletRequest request,
    		HttpServletResponse response) throws Exception {
    	System.out.println("[ERROR] No Handler Found.");
    	executeRequest();
    }

    private void executeRequest() throws Exception {
    	
    	WebApplicationContext context = getWebApplicationContext();
    	BagBean bag = ( BagBean ) context.getBean( "BagBean" );
		System.out.println( bag.getMessage() );
	}
	
	
}
